namespace FIREFLYX {
    export type MaterialGroup = Material[];
    export abstract class Renderer extends Component implements IEnabled {
        protected static _useSign: ComponentUseSign = "renderer";
        /** 该渲染器所有的材质实例 */
        protected _materialGroupList: MaterialGroup[] = [[]];
        protected _castShadows: boolean = true;
        protected _receiveShadows: boolean = true;
        protected _isVisible: boolean = false;
        protected _enable: boolean = true;

        /** 渲染材质组 , 组中每一个材质对应一次绘制，顺序依次绘制*/
        public get materialGroup(): MaterialGroup {
            const list = this._materialGroupList;
            if (list.length < 1) { list[0] = []; }
            return list[0]; //返回 0 的 materials
        }

        /** 渲染材质组 列表 , 列表中每个组对应每个 primitive 的绘制, 例如： materialGroupList[0] 对应第一个primitive , [1] 第二...*/
        public get materialGroupList(): MaterialGroup[] { return this._materialGroupList; }

        /**
         * 获取网格顶点数据 数量
         */
        public getVertexDataCount() {
            return 0;
        }

        /**
         * 上传网格顶点数据和状态
         * @param index 数据索引
         * @param out 返回结果数据
         */
        public uploadVertexData(index: number, out: IRendererVDataResult): void {
            return;
        }

        /** 是否投射阴影 */
        public get castShadows() { return this._castShadows; }
        public set castShadows(val) { this._castShadows = val; }
        /** 是否接收阴影 */
        public get receiveShadows() { return this._receiveShadows; }
        public set receiveShadows(val) { this._receiveShadows = val; }
        /** 是否在相机中可见 */
        public get isVisible() { return this._isVisible; }
        /** 是否是启用渲染 */
        public get enabled() { return this._enable; }
        public set enabled(val) { this._enable = val; }

        public dispose(): void {
            super.dispose();
            this._materialGroupList.length = 0;
        }
    }
}